/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** ************************************************************************************************
 *  \file     Firewall_Mac.h                                                                  *
 *  \brief    This file contains interface header for Semidrive Firewall MAC module.                    *
 *                                                                                                 *
 **************************************************************************************************/

#ifndef FIREWALL_MAC_H
#define FIREWALL_MAC_H

#ifdef __cplusplus
extern "C" {
#endif

/***************************************************************************************************
 *                                      Include header files                                       *
 **************************************************************************************************/
#include <Firewall.h>

/***************************************************************************************************
 *                                  Global Function Declarations                                   *
 **************************************************************************************************/
/**
 * \brief Configure the mapping between masters and domains in MAC module.
 *
 * This function configure the mapping between masters and domains in MAC module.
 * The System should call Firewall_MacLockDomainAssignment() to lock the MAC
 * configurations after calling this function.
 *
 * \param[in] ctrl the firewall instance.
 * \param[in] mac_cfg the configuration of the MAC.
 *
 * \return The result of the MAC initialization function
 * \details - return FIREWALL_E_OK : initializa MAC success.
 *          - return FIREWALL_E_NULL_POINTER : The pointer is a NULL_PTR.
 */
lld_status_t Firewall_MacConfigure(const Firewall_ControllerType *ctrl,
                                     const Firewall_MacConfigType *macConfigPtr);

/**
 * \brief Assigns the specified master to a domain.
 *
 * This function is called by Firewall_AssignDomain().
 *
 * \param[in] macBaseAddr the address of the MAC module.
 * \param[in] master_id the id of the master.
 * \param[in] domain_id the id of the domain.
 *
 * \return    The result of this function.
 * \details - return FIREWALL_E_OK : Change domain success.
 *          - return FIREWALL_E_MAC_MASTER_ID : invalid master id.
 *          - return FIREWALL_E_MAC_DOMAIN_ID : invalid domain id.
 *          - return FIREWALL_E_MAC_LOCKED : domain assign has been locked.
 */
lld_status_t Firewall_MacAssignDomain(uint32_t macBaseAddr, uint8_t master_id,
                                         uint8_t domain_id);

/**
 * \brief Lock the configuration of the map between masters and domains
 *        in MAC module.
 *
 * This function lock the configuration of map between masters and domains
 * in MAC module.
 * This function is called by Firewall_LockDomainAssignment().
 *
 * \param[in] macBaseAddr the address of the MAC module.
 */
void Firewall_MacLockDomainAssignment(uint32_t macBaseAddr);

/**
 * \brief Clear the interrupt status of the MAC module.
 *
 * \param[in] macBaseAddr the address of the MAC module.
 */
void Firewall_MacClearInterrupt(uint32_t macBaseAddr);

#ifdef __cplusplus
}
#endif

#endif /* FIREWALL_MAC_H */

/* End of file */
